<template>
<div>
  <Table border :columns="columns" :data="data">
    <template slot-scope="{ row }" slot="userDO.name">
      <strong>{{ row.userDO.name }}</strong>
    </template>
    <template slot-scope="{ row }" slot="informationDO.name">
      <strong>{{ row.informationDO.name }}</strong>
    </template>

    <template slot-scope="{ row, index }" slot="action">
      <Button type="primary" size="small" style="margin-right: 5px" @click="show">确认</Button>
      <Button type="error" size="small" @click="remove(row)">删除</Button>
    </template>
  </Table>
</div>
</template>

<script>
export default {
  name: "borrowing",
  data () {
    return {
      columns: [
        {
          title: '借书人',
          slot: 'userDO.name'
        },
        {
          title: '已借书籍',
          slot: 'informationDO.name'
        },
        {
          title: '借出时间',
          key: 'lend_date'
        },
        {
          title: '归还时间',
          key: 'back_date'
        },
        {
          title: '归还类型',
          key: 'type'
        },
        {
          title: '备注',
          key: 'remarks'
        },
        {
          title: 'Action',
          slot: 'action',
          width: 150,
          align: 'center'
        }
      ],
      data: []
    }
  },
  methods: {
    show (index) {

    },
    remove (row) {
      this.$confirm("确定删除吗？","提示").then(()=>{
        this.http.post("/DeleteBorrow",this.qs.parse(row)).then(res=>{
          if (res.data){
            this.$Message.success('删除成功')
            this.getBorrow();
          }else{
            this.$Message.error('删除失败')
          }
        })
      })
    },
    getBorrow(){
      this.http.post("/getBorrow").then(res=>{
        if (res.data){
          console.log(res.data)
          this.data=res.data;
        }
      })
    }
  },
  created() {
    this.getBorrow();
  }
}
</script>

<style scoped>

</style>